Check whether a string contains another string.

Hello All.

I have to check whether a string is a part of another string using dxl.

For example : String source = "Qualified order ready for implementation"

String check = "Qualified".

Is there any string handling functions available to check:

if(source.contains(check)){

print "Substring is present"

}

I couldn't find any API's. also.. use of regex is not needed as the pattern is fixed.

Kindly share your suggestions


Adminani - Wed Feb 11 04:13:17 EST 2015

Re: Check whether a string contains another string.
O.Wilkop - Wed Feb 11 04:59:55 EST 2015

Check out the function "findPlainText" for strings or the function "contains" for Buffer

 

string check = "Qualified"
string source = "xyz Qualified xyz"
string source2 = "xyz xyz"

int offset
int length

if(findPlainText(source, check, offset, length, true)){
        print "source contains check at position "offset "\n"
}else{
        print "source does not contain check\n"
}
if(findPlainText(source2, check, offset, length, true)){
        print "source2 contains check at position " offset "\n";
}else{
        print "source2 does not contain check\n"
}